package cn.itcast.jdbc;

import java.sql.*;

public class jdbcDemo01 {
    public static void main(String[] args) throws SQLException {
//        // 注册驱动
//        DriverManager.registerDriver(new com.mysql.jdbc.Driver());
        // 获取连接
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb16_jdbc","root","my123456");
        //执行SQL
        Statement statement = connection.createStatement();
        // 增加数据
//        int rows = statement.executeUpdate("insert into student values(NULL,'鲁智深',40)");
        // 修改数据
//        int rows2 = statement.executeUpdate("update student set age = 48 where sname='武松'");
        // 删除数据
        int rows3 = statement.executeUpdate("delete from student where sname = '鲁智深'");


        System.out.println(rows3);

        //关闭连接

        statement.close();
        connection.close();

    }
}
